<template>
  <div class="carousel">
    <div class="carousel-inner" :style="{ transform: `translateX(-${currentIndex * 100}%)` }">
      <div class="carousel-item" v-for="(item, index) in items" :key="index">
        <img :src="item" alt="Carousel Item">
      </div>
    </div>
    <div class="carousel-controls">
      <button @click="prev">Previous</button>
      <button @click="next">Next</button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Carousel',
  data() {
    return {
      currentIndex: 0,
      items: [
        'public\fengjing1.jpeg',
        'public\fengjing2.jpeg',
        'public\about.webp'
      ]
    };
  },
  methods: {
    prev() {
      this.currentIndex = this.currentIndex > 0 ? this.currentIndex - 1 : this.items.length - 1;
    },
    next() {
      this.currentIndex = this.currentIndex < this.items.length - 1 ? this.currentIndex + 1 : 0;
    }
  }
};
</script>

<style scoped>
.carousel {
  width: 800px;
  height: 400px;
  overflow: hidden;
  position: relative;
}

.carousel-inner {
  display: flex;
  transition: transform 0.5s ease-in-out;
}

.carousel-item {
  min-width: 100%;
  height: 100%;
}

.carousel-controls {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
}
</style>